<template>
  <div class="page-mobile-wrong__question"></div>
</template>

<script>
import { mapState, mapActions, mapMutations } from "vuex";
import { getTest } from "~/api/test";
export default {
  components: {},
  data() {
    return {
      course_obj: {}
    };
  },
  computed: {
    ...mapState({
      user_info(state) {
        return state.user_info;
      },
      major_list(state) {
        return state.major_list;
      }
    })
  },
  watch: {},
  methods: {
    ...mapActions(["initMajorList"]),
    ...mapMutations(["SET_IS_LOADING"]),
    async getData() {
      return new Promise(async (res, rej) => {
        this.SET_IS_LOADING(true);
        let result = await getTest({
          id: this.courseId
        });
        if (result && result.data && result.data.code == 200) {
          const { data } = result.data;
          if (data && data.rows && data.rows.length > 0) {
            this.course_obj = data.rows[0];
          }
        } else {
          this.$toast(
            this.$t("locale.mobile.wrongQuestion.t1") + result &&
              result.data &&
              result.data.msg
          );
        }
        this.SET_IS_LOADING(false);
        res();
      }).then();
    },
    getMajorName(item) {
      let res = this.major_list.filter(i => i.id == item.majorId);
      if (res.length > 0) {
        return res[0].name;
      } else {
        return this.$t("locale.mobile.wrongQuestion.unknow");
      }
    }
  },
  created() {
    this.getData();
    this.initMajorList();
  },
  mounted() {}
};
</script>

<style lang="scss" scoped>
.page-mobile-wrong__question {
}
</style>
<style lang="scss">
.page-mobile-wrong__question {
}
</style>
